package bean;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import util.Util;

@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Data
public class Student extends Person {
    private int number;
    private int state;
    private int score;

    public Student(int number, int state, int score) {
        this(state, score);
        this.number = number;
    }

    public Student(String name, int age, int state, int score) {
        super(name, age);
        this.state = state;
        this.score = score;
    }

    public Student() {
    }

    public Student(int state, int score) {
        this.state = state;
        this.score = score;
    }

    @Override
    public void eat() {
        System.out.println("The student is eating...");
    }

    public static void bubbleSort(Student[] s) {
        boolean flag;
        Student tmp;
        for (int i = 0; i < s.length; i++) {
            flag = true;
            for (int j = 0; j < s.length - i - 1; j++) {
                if (s[j].getScore() < s[j + 1].getScore()) {
                    tmp = s[j];
                    s[j] = s[j + 1];
                    s[j + 1] = tmp;
                    flag = false;
                }
            }
            if (flag)
                return;
        }
    }

    public static void bubbleSort(Student[] s, boolean up) {
        if (up) {
            bubbleSort(s);
            Util.reverse(s);
        } else
            bubbleSort(s);
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("空间被释放----->" + this);
    }
}
